package sysu.el.array.ints.algors;

public class RepeatedElem {
	static public boolean detect(int num, int a[]){
		assert(InOrder.asc(num, a) || InOrder.des(num, a));
		for (int i=1; i<num; i++)
			if (a[i-1] == a[i])
				return true;
		return false;
	}
	
	static public int eliminate(int num, int a[]){
		assert(InOrder.asc(num, a) || InOrder.des(num, a));
		int c = 0;
		for (int i=1; i<num; i++)
			if (a[c] != a[i]){
				a[++c] = a[i];
			}
		return c+1;
	}
}
